package com.nus.iss.ad.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MyUtilities {
	public static String dateToString(Date date,String dateFormat){
		SimpleDateFormat smf=new SimpleDateFormat(dateFormat);
		String result="";
		result=smf.format(date);
		return result;
	}
	
	   public static boolean isValidNumber(Class c, String numString) {
     	  try {
     	    if (c == double.class || c == Double.class) {
     	      Double.parseDouble(numString);
     	    } else if (c == int.class || c == Integer.class) {
     	      Integer.parseInt(numString);
     	    } else if (c == float.class || c == Float.class) {
     	      Float.parseFloat(numString);
     	    } else if (c == long.class || c == Long.class) {
     	      Long.parseLong(numString);
     	    }
     	  } catch (Exception ex) {
     	    return false;
     	  }
     	  return true;
     	}
      
}
